package com.zcyh.exam.parser.imports;

import com.zcyh.exam.model.entity.QuestionInfo;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @author zengjintao
 * @version 1.0
 * @create_at 2021/1/16 15:03
 */
@Data
public abstract class QuestionImportResult {

    private final InputStream inputStream;
    private MultipartFile file;
    private HttpServletResponse response;
    /**错误提示文件路径url*/
    private String errorFileUrl;
    /**文件是否有内容*/
    private boolean hasData = true;
    /**导入成功试题*/
    private List<QuestionInfo> successImportQuestionList;
    /**导入失败试题*/
    private List<QuestionInfo> failImportQuestionList;
    /**错误提示信息*/
    private String errorMsg;

    public QuestionImportResult(MultipartFile file) throws IOException {
        this.file = file;
        this.inputStream = file.getInputStream();
    }

    public QuestionImportResult(MultipartFile file, HttpServletResponse response) throws IOException {
        this.file = file;
        this.inputStream = file.getInputStream();
        this.response = response;
    }
    public abstract void readTemplate();
}
